-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add better error messages for dotnet test with solution/project/directory/dll arguments in Microsoft.Testing.Platform (MTP) #50108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…rguments Co-authored-by: Youssef1313 <[email protected]>
--solution
, --project
, --directory
, or --test-modules
in dotnet test… for file/directory arguments Co-authored-by: Youssef1313 <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot Revert all changes in src/Cli/dotnet/Commands/Test/TestCommand.cs
Co-authored-by: Youssef1313 <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds validation for Microsoft Testing Platform (MTP) to provide better error messages when users run dotnet test
with file or directory arguments as positional parameters instead of using the appropriate command-line flags.
- Validates file/directory arguments and suggests using proper flags (
--solution
,--project
,--directory
,--test-modules
) - Adds comprehensive test coverage for all validation scenarios in the MTP command path
- Updates localization files with new error messages
Reviewed Changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
src/Cli/dotnet/Commands/Test/ValidationUtility.cs |
Adds new validation method to detect file/directory arguments and provide helpful error messages |
src/Cli/dotnet/Commands/Test/TestingPlatformCommand.cs |
Integrates validation into the MTP command execution path |
src/Cli/dotnet/Commands/CliCommandStrings.resx |
Adds English resource strings for the new error messages |
src/Cli/dotnet/Commands/xlf/*.xlf |
Updates localization files with new error message entries marked as "new" |
test/dotnet.Tests/CommandTests/Test/TestCommandValidationTests.cs |
Adds comprehensive test coverage for validation scenarios |
… .resx and .xlf files Co-authored-by: Youssef1313 <[email protected]>
What are positional arguments used for? If most users are trying to run |
We explicitly decided to not support it. |
When users run
dotnet test
with file or directory arguments as positional parameters, they previously received confusing MSBuild or VSTest errors. This PR adds validation to detect these patterns and provide helpful guidance for Microsoft Testing Platform (MTP) users.Problem
Users often try commands like:
dotnet test MySolution.sln
dotnet test MyProject.csproj
dotnet test path/to/directory
dotnet test test.dll
These would result in confusing errors like:
Solution
Added validation in the Microsoft Testing Platform command path (
TestingPlatformCommand.cs
) to detect file/directory arguments and suggest using the appropriate flags directly (--solution
,--project
,--directory
,--test-modules
).Examples
Before:
After (when MTP is enabled):
Implementation Details
TestCommand.cs
) remains unchanged to preserve existing behaviorFixes #49710.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.